package com.booza.dao;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.booza.model.PlayerStatus;

@Transactional
public class PlayerStatusDAOImpl implements PlayerStatusDAO
{
	@Autowired
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory()
	{
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory)
	{
		this.sessionFactory = sessionFactory;
	}

	@Override
	public PlayerStatus findPlayerStatus(int id)
	{
		return (PlayerStatus) sessionFactory.getCurrentSession().get(PlayerStatus.class, id);
	}

	@Override
	public void updatePlayerStatus(PlayerStatus status)
	{
		sessionFactory.getCurrentSession().saveOrUpdate(status);
	}

	@Override
	public void insertPlayerStatus(PlayerStatus status)
	{
		sessionFactory.getCurrentSession().save(status);
	}
}
